package com.zueb.util;

import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

public class ResponseWriterUtils {

    public static void writer(Map map, HttpServletResponse response){
        try {
            String jsonString = JSON.toJSONString(map);

            response.setContentType("text/html;charset=utf-8");

            response.getWriter().println(jsonString);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void writerFlag(int flag, HttpServletResponse response){
        try {
            if (flag == 1) {
                response.getWriter().write("true");
            } else {
                response.getWriter().write("false");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
